<?php
ini_set('display_errors', 1);
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);

require_once("/../initialize.php");

for($i=0;$i<750;$i++){
    
    
   $input = array("male","female","male","female");
    $rand_keys = array_rand($input, 2);

  $length = 10;
  $length1 = 4;
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJILKNMOPQRSTWVXYZ';
    $characters1 = 'abcdefghijklmnopqrstuvwxyz';
    $numbers = '0123456789';
    $string = "";
    $string1 = "";
    $string2 = "";
    $string3 = "";
    $string4 = "19";


        
         $uregistergender = $input[$rand_keys[1]];
        $uregisterfirstname     =  "Fornavn".$i;
        $uregisterlastname      =  "Etternavn".$i;
        $uregistervisningsnavn  = "Vvisningsnavn".$i;
        $uregisteremail         = "EEepost".$i."@epost.no";
  
  
        $uregisterzip           = rand(2001, 9001);
    
     
        $uregisterborn          = rand(1940, 2005);
        
        
         
        $uregisterpassword      = "Pass0rd".$i;
        $uregisterpassword1     = "Pass0rd".$i;
    
        
        if(!Login::existingEmail($uregisteremail)){
            $uregisterloaction = new Location;
            echo "test";
           
            if(is_string($uregisterloaction->findLocationName($uregisterzip))){
                
            $uregister              = new User();
            $uregister->firstname   = $uregisterfirstname;
            $uregister->lastname    = $uregisterlastname;
            $uregister->username    = $uregistervisningsnavn;
            $uregister->zipcode     = $uregisterzip;
            $uregister->yearborn    = $uregisterborn;
            $uregister->sex         = $uregistergender;
                
                if($uregisterpassword == $uregisterpassword1){
           
                        if (preg_match("#.*^(?=.{6,20})(?=.*[a-å])(?=.*[A-Å])(?=.*[0-9]).*$#", $uregisterpassword)){
            
               
                                    $ulregister = new Login();        
                                    $ulregister->email          = $uregisteremail;
                                    $uregisterpassword3         = sha1($uregisterpassword);
                                    $ulregister->password       = $uregisterpassword3;
                                    $activtedstring             = $ulregister->createaAString($uregisteremail,$uregisterpassword3);
                                    $ulregister->activatestring = $activtedstring;
                                    
                                    $uregister->save();
                                    $uregisterid                = $uregister->id;
                                    $ulregister->user_id        = $uregisterid;

                                    $ulregister->save();
                                    /*
                                    $to = $uregisteremail;
                                    $subject = "Ny Bruker i Forbrukermakt.com";
                                    $message = "Velkommen som ny bruker hos forbrukermakt.com, for å kunne bruke din konto er du nødt til å aktivere denne, det gjør du 
                                        på følgende side= http://localhost/aktivering.php?activ={$activtedstring}";
                                    $from = "noreply@flowershopfucker.no";
                                    $headers = "From:" . $from;
                                    mail($to,$subject,$message,$headers);
                                    */
                                   // redirect_to("/public/activation.php?activ={$activtedstring}");
                                  
                                     

                        }else{
                            $message .= "Passordet ditt er for svakt, vennligst bruk minimum 6 tegn, Minimum en stor bokstav og tall";
                        }
       
                }else{
                    $message .= "Passordene du har skrevet inn stemmer ikke overens.";
                }
        }else{
            $message .= "Postnummeret eksister ikke";
        }

    }else{
        $message .= "Mailadressen er allerede registert. <p></p>";
    }
}

?>
